// Copyright (c) 2023 刻BITTER
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.


#include <data_basic.hpp>

#include "app.hpp"
#include "between_face_common.hpp"
#include "modbus_client.hpp"
#include "oled.hpp"
#include "u8g2_font_menu_chs.hpp"
#include "ui.hpp"


/////////////////////// PIN MAPPING /////////////////////////

const ioxx::Pin LED_PIN = m128::LED_PIN;


/////////////////////// TOP LEVEL GLOBALS /////////////////////////

Scheduler dcb;


///////////////////////  MAIN    ////////////////////////////

TimeType task_blink() {
    LED_PIN.toggle();
    return 800;
}


CountScreen cs;
AddressScreen as;


void loop() {
    dcb.tick();

    cs.enter();
}


void setup() {
    // Wire.begin();

    Serial.begin(115200);
    Serial1.begin(9600);

    pinMode(LED_PIN, OUTPUT);

    init_oled();
    init_modbus_client();
    init_buttons();

    dcb.add_task(task_blink, 0);
    dcb.add_task(task_scan_button, 0);
}